<template>
	<view class="pagecon">
		<head-box :navigationBarTitleText="title"></head-box>
			<view class="page_mian tab-botton">
				<view class="banner">
					<image :src="TypeIndex == 4 ? '/static/img/wyhs_banner.png' :  '/static/img/wycy_banner.png' " mode="aspectFill"></image>
				</view>
				<view class="quntuanListPage-main-header">
					<div class="quntuanListPage-main-title">{{title}}</div>
				</view>
				<view class="personalInfor-page-main">
					<view class="personalInfor-page-main-box">
						<view class="_main-item" style="display: none;">
							<view class="_main-item-chunk _main-item-label"><text>请选择群团</text></view>
							<view class="_main-item-chunk _main-item-val">
								<picker class="_main-item-val-input" @change="changea" :value="chooseTypeIndex" :range="chooseTypeArr">
									<view class="uni-input _main-item-val-input-text">
										{{chooseTypeArr[chooseTypeIndex]}}
										<image class="drop-dowm-img" src="../../static/img/drop-down.png" mode=""></image>
									</view>
								</picker>
							</view>
						</view>

						<view class="_main-item" >
							<view class="_main-item-chunk _main-item-label"><text></text></view>
							<view class="_main-item-chunk _main-item-val">
								<picker :disabled="suo" class="_main-item-val-input" @change="changetype" :value="TypeIndex" :range="TypeArr" >
									<view class="uni-input _main-item-val-input-text">
										{{TypeArr[TypeIndex]}}
										<image class="drop-dowm-img" src="../../static/img/drop-down.png" mode=""></image>
									</view>
								</picker>
							</view>
						</view>
					</view>
				</view>
				<view>
					<textarea cursorSpacing="10" class="textarea" v-model="advice" :placeholder="message"></textarea>
				</view>
				<view class="subbtn">
					<button type="primary"  @click="submit">提交</button>
				</view>
			</view>
		<tabs-box></tabs-box>
	</view>
</template>

<script>
	import { mapState,mapMutations} from 'vuex';
	import { gpUseradvisesubmit,gpGpinfoList } from '@/common/request.js';
	export default {
		data() {
			return {
				message:'',
				advice:'',
				chooseTypeArr:[],
				chooseTypeArrall:[],
				chooseTypeIndex: 0,
				TypeArr:["请选择","我有活动要发布","我来奉献","我有金点子","我要留言"],
				TypeArrall:["0","2","5","4","6"],
				TypeIndex: 0,
				pageSize:20,
				pageNo:1,
				suo:false,
				title:"我要参与"

			};
		},
		computed: {
			...mapState(['hasLogin', 'userInfo','token'])
		},
		onLoad(options) {
			console.log(options.id);
			if(options.id != undefined){

				this.TypeIndex = options.id;
				this.suo = true;
				console.log(options.id,this.suo)
				if(this.TypeIndex == 4)
				{
					this.title = "我要留言";
					uni.setNavigationBarTitle({ title: '我要留言' });
				}

				if(this.TypeIndex == 3 || this.TypeIndex == 4)
					this.message="请说出您想对我们说的话";
				else if(this.TypeIndex == 2)
					this.message = "请输入您可以为老百姓做什么";
				else
					this.message = "";
			}

			this.getList();
		},
    onShow(){
      // #ifdef H5
      console.log('分享')
      this.$wxSetShare()
      // #endif
    },
		methods: {
			submit()
			{
				if(this.TypeIndex == 0)
				{
					this.$api.msg('请选择类型');
					return;
				}
				if(this.advice =='')
				{
					this.$api.msg('请输入您要对我们说的话');
					return;
				}
				var params ={"adviseContent": this.advice,"useradviseType":this.TypeArrall[this.TypeIndex],"gpinfoId":this.chooseTypeArrall[this.chooseTypeIndex]}
				console.log(params);
				gpUseradvisesubmit(params).then(res => {
					console.log(res)

					if(res.success)
					{
						this.$api.msg('提交成功,感谢您的建议');
						this.advice = '';
						setTimeout(() => {
							uni.navigateTo({
								url:'/pages/mySuggestion/mySuggestion'
							})
						}, 1000);
					}
				});
			},
			changea(e) {
				console.log('picker发送选择改变，携带值为', e.target.value)
				this.chooseTypeIndex = e.target.value
				console.log(this.chooseTypeArrall[this.chooseTypeIndex]);

				//this.GetList()
			},
			changetype(e) {
				console.log('picker发送选择改变，携带值为', e.target.value)
				this.TypeIndex = e.target.value
				if(this.TypeIndex == 3 || this.TypeIndex == 4)
					this.message="请说出您想对我们说的话";
				else if(this.TypeIndex == 2)
					this.message = "请输入您可以为老百姓做什么";
				else
					this.message = "";
				console.log(this.TypeArrall[this.TypeIndex]);
				//this.GetList()
			},
			getList()
			{
				var that = this
				let params = {}
				gpGpinfoList(that.pageSize,that.pageNo,params).then(res => {
					if(res.success)
					{
						that.chooseTypeArr = []
						if(res.result.records.length>0)
						{
							res.result.records.forEach(ele => {
								that.chooseTypeArrall.push(ele.id);
								that.chooseTypeArr.push(ele.gpinfoName)
							})
						}
						else
							that.loadingMoreDefaultText ='';
					}
				});
			},
		}
	}
</script>

<style lang="scss">
	.pagecon{
		height: 100vh;
		.page_mian{
			padding: 30rpx;
			.banner{
				width: 100%;
				height: 280rpx;
				margin-bottom: 60rpx;
				image{
					width: 100%;
					height: 100%;
					border-radius: 10rpx;
				}
			}

			.quntuanListPage-main-title{
				font-size: 32rpx;
				color: #333;
				font-weight: 600;
				border-left: 6rpx solid #0071fc;
				background-image:linear-gradient(left, #eff6ff, #ffffff);
				padding-left: 20rpx;
			}

			.textarea{
				border-radius: 10rpx;
				border: 1px solid #cccccc;
				padding: 20rpx;
				width: calc(100% - 40rpx);
				margin-top: 50rpx;
			}
			.subbtn{
				margin-top: 50rpx;
			}
		}

		.personalInfor-page-main{
			width: 100%;
			box-sizing: border-box;
			margin-top: 40rpx;
			.personalInfor-page-main-box{
				width: 100%;
				._main-item{
					// height: 86rpx;
					border-bottom: 1px solid rgba(200,199,204,0.5);
					display: flex;
					flex-wrap: nowrap;
					justify-content: space-between;
					align-items: center;
					._main-item-chunk{
						font-size: 34rpx;
						color: #000;
						line-height: 84rpx;
					}
					._main-item-label{
						width: 30%;
					}
					._main-item-val{
						width: 70%;
						display: flex;
						flex-wrap: nowrap;
						justify-content: flex-end;
						align-items: center;
						._main-item-val-head{
							width: 48rpx;
							height: 48rpx;
							border-radius: 50%;
							display: flex;
							.head-img{
								width: 100%;
								height: 100%;
								border-radius: 50%;
							}
						}
						._main-item-val-input{
							text-align: right;
							display: flex;
							._main-item-val-input-text{
								display: flex;
								flex-wrap: nowrap;
								align-items: center;
							}
							.drop-dowm-img{
								width: 30rpx;
								height: 30rpx;
								margin-left: 10rpx;
								transform: rotateZ(270deg);
							}
						}
						.drop-dowm-img{
							width: 30rpx;
							height: 30rpx;
							margin-left: 10rpx;
							transform: rotateZ(270deg);
						}
					}
				}

			}
		}
	}
</style>
